// import com.alibaba.druid.sql.ast.SQLExpr;
// import com.alibaba.druid.sql.ast.SQLName;
// import com.alibaba.druid.sql.ast.SQLObject;
// import com.alibaba.druid.sql.ast.SQLStatementImpl;
// import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "SQLAlterSequenceStatement.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../SQLExpr.h"
#include "../SQLName.h"
#include "../expr/SQLPropertyExpr.h"
#include "../../../utils/instanceof.h"

SQLAlterSequenceStatement::SQLAlterSequenceStatement()
{
}

// @Override
void SQLAlterSequenceStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLAlterSequenceStatement)))
  {
    acceptChild(visitor, name);
    acceptChild(visitor, startWith);
    acceptChild(visitor, incrementBy);
    acceptChild(visitor, minValue);
    acceptChild(visitor, maxValue);
  }
  visitor->endVisit(SharedObject(SQLAlterSequenceStatement));
}

// @Override
SQLObject_list_ptr SQLAlterSequenceStatement::getChildren()
{
  SQLObject_list_ptr children = std::make_shared<std::list<SQLObject_ptr>>();
  if (name != nullptr)
  {
    children->push_back(name);
  }
  if (startWith != nullptr)
  {
    children->push_back(startWith);
  }
  if (incrementBy != nullptr)
  {
    children->push_back(incrementBy);
  }
  if (minValue != nullptr)
  {
    children->push_back(minValue);
  }
  if (maxValue != nullptr)
  {
    children->push_back(maxValue);
  }
  return children;
}

SQLName_ptr SQLAlterSequenceStatement::getName()
{
  return name;
}

void SQLAlterSequenceStatement::setName(SQLName_ptr name)
{
  this->name = name;
}

SQLExpr_ptr SQLAlterSequenceStatement::getStartWith()
{
  return startWith;
}

void SQLAlterSequenceStatement::setStartWith(SQLExpr_ptr startWith)
{
  this->startWith = startWith;
}

SQLExpr_ptr SQLAlterSequenceStatement::getIncrementBy()
{
  return incrementBy;
}

void SQLAlterSequenceStatement::setIncrementBy(SQLExpr_ptr incrementBy)
{
  this->incrementBy = incrementBy;
}

SQLExpr_ptr SQLAlterSequenceStatement::getMaxValue()
{
  return maxValue;
}

void SQLAlterSequenceStatement::setMaxValue(SQLExpr_ptr maxValue)
{
  this->maxValue = maxValue;
}

BOOL_ptr SQLAlterSequenceStatement::getCycle()
{
  return cycle;
}

void SQLAlterSequenceStatement::setCycle(BOOL_ptr cycle)
{
  this->cycle = cycle;
}

BOOL_ptr SQLAlterSequenceStatement::getCache()
{
  return cache;
}

void SQLAlterSequenceStatement::setCache(BOOL_ptr cache)
{
  this->cache = cache;
}

BOOL_ptr SQLAlterSequenceStatement::getWithCache()
{
  return withCache;
}

void SQLAlterSequenceStatement::setWithCache(BOOL_ptr withCache)
{
  this->withCache = withCache;
}

BOOL_ptr SQLAlterSequenceStatement::getOrder()
{
  return order;
}

void SQLAlterSequenceStatement::setOrder(BOOL_ptr order)
{
  this->order = order;
}

SQLExpr_ptr SQLAlterSequenceStatement::getMinValue()
{
  return minValue;
}

void SQLAlterSequenceStatement::setMinValue(SQLExpr_ptr minValue)
{
  this->minValue = minValue;
}

BOOL_ptr SQLAlterSequenceStatement::isNoMaxValue()
{
  return noMaxValue;
}

void SQLAlterSequenceStatement::setNoMaxValue(BOOL_ptr noMaxValue)
{
  this->noMaxValue = noMaxValue;
}

BOOL_ptr SQLAlterSequenceStatement::isNoMinValue()
{
  return noMinValue;
}

void SQLAlterSequenceStatement::setNoMinValue(BOOL_ptr noMinValue)
{
  this->noMinValue = noMinValue;
}

string_ptr SQLAlterSequenceStatement::getSchema()
{
  SQLName_ptr name = getName();
  if (name == nullptr)
  {
    return nullptr;
  }

  if (instanceof <SQLName, SQLPropertyExpr>(name))
  {
    return (std::dynamic_pointer_cast<SQLPropertyExpr>(name))->getOwnernName();
  }

  return nullptr;
}

SQLExpr_ptr SQLAlterSequenceStatement::getCacheValue()
{
  return cacheValue;
}

void SQLAlterSequenceStatement::setCacheValue(SQLExpr_ptr cacheValue)
{
  if (cacheValue != nullptr)
  {
    cacheValue->setParent(SharedObject(SQLAlterSequenceStatement));
  }
  this->cacheValue = cacheValue;
}

BOOL_ptr SQLAlterSequenceStatement::isChangeToSimple()
{
  return changeToSimple;
}

void SQLAlterSequenceStatement::setChangeToSimple(BOOL_ptr changeToSimple)
{
  this->changeToSimple = changeToSimple;
}

BOOL_ptr SQLAlterSequenceStatement::isChangeToGroup()
{
  return changeToGroup;
}

void SQLAlterSequenceStatement::setChangeToGroup(BOOL_ptr changeToGroup)
{
  this->changeToGroup = changeToGroup;
}

BOOL_ptr SQLAlterSequenceStatement::isChangeToTime()
{
  return changeToTime;
}

void SQLAlterSequenceStatement::setChangeToTime(BOOL_ptr changeToTime)
{
  this->changeToTime = changeToTime;
}

BOOL_ptr SQLAlterSequenceStatement::isRestart()
{
  return restart;
}

void SQLAlterSequenceStatement::setRestart(BOOL_ptr restart)
{
  this->restart = restart;
}

SQLExpr_ptr SQLAlterSequenceStatement::getRestartWith()
{
  return restartWith;
}

void SQLAlterSequenceStatement::setRestartWith(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterSequenceStatement));
  }
  this->restartWith = x;
}

// @Override
SQLDDLStatement::DDLObjectType SQLAlterSequenceStatement::getDDLObjectType()
{
  return SQLDDLStatement::DDLObjectType::SEQUENCE;
}
